<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <style>
        body{
            height:100%;
        }
        main {
            width: 300px;
            height: 40px;
            margin: 200px auto;
            border: 1px solid red;
        }

        ul {
            margin-top: 0px;
            list-style: none;
            padding: 0;
        }

        .first {
            width: 180px;
            height: 40px;
            background-color: red;
            text-align: center;
            line-height: 40px;
            font-size: 25px;
        }

        .second {
            width: 120px;
            height: 40px;
            background-color: greenyellow;
            text-align: center;
            line-height: 40px;
            font-size: 25px;
            cursor: pointer;
        }

        .one li {
            float: left;
        }

        .two {
            float: right;
            border: 1px solid blue;
            display: none;
        }

        .two li {
            font-size: 25px;
            cursor: pointer;
            border-top: 1px dashed black;
            border-bottom: 1px dashed black;
        }
    </style>
</head>

<body>
    <main>
        <ul class="one">
            <li class="first">选择项目</li>
            <li class="second">未选择</li>
        </ul>
        <ul class="two">
            <li>HTML</li>
            <li>CSS</li>
            <li>JavaScript</li>
            <li>Jqurey</li>
        </ul>
    </main>
    <script src="jqurey.js"></script>
</body>

</html>
<script>
    var second = $('.second');
    second.click(function (ev) {
        $('.two').css('display', 'block');
        ev.stopPropagation();
    })
    $('.two li').hover(function () {
        $(this).css('background-color', 'gray');
        $(this).click(function () {
            $('.second').text($(this).text());
            $('.two').css('display','none');
        })
    }, function(){
        $(this).css('background-color', 'white');
        $(this).click(function () {
            $('.second').text($(this).text());
            $('.two').css('display','none');
        })
    }
    )
            $('body').click(function(){
           console.log('second');
           $('.two').css('display','none');
    })
    

</script>